<%# The "div"s here are not balanced within the file.
    That allows us to fill in and then end the current column & row,
    followed by starting and finishing another full row. %>
<% badge_hostname = (ENV['PUBLIC_HOSTNAME'] || 'localhost') %>
<%# TODO: Use badge_percentage_1 %>
<% provide :insert_progress_bar do %>
  <div class="progress-mobile progress">
    <div class="progress-bar progress-bar-success badge-progress"
         role="progressbar" aria-valuenow="<%= project.badge_percentage_2 %>"
         aria-valuemin="0" aria-valuemax="100">
      <%= project.badge_percentage_2 %>%
    </div>
  </div>
<% end %>
<%= render(partial: 'form_early',
           locals:
             {
               project: project, view_only: view_only,
               criteria_level: '2', badge_hostname: badge_hostname
             }) %>

<div class="row">
  <div class="col-md-12">
 <div>
  <%= bootstrap_form_for project, url: project_path(project, criteria_level: '2') do |f| %>
    <%= render 'shared/error_messages', object: f.object %>
    <%= f.hidden_field :lock_version %>

  <br>

  <div class="panel-group well well-lg well-color">
    <div class="panel panel-primary">
      <%= render(partial: 'panel_header',
           locals:
             {
               panel_title: 'Basics', anchor_id: 'basics',
               by_default: 'open',
               satisfaction_data:
                 project.get_satisfaction_data('2','basics')
             }) %>
      <div class="panel-collapse collapse in">
        <ul class="list-group">
          <li class="list-group-item"><h3 id="section_identification"><%= t('headings.Identification') %></h3>
            <%= render(partial: 'form_basics',
                 locals:
                   {
                     project: project, view_only: view_only,
                     badge_hostname: badge_hostname, f: f,
                     criteria_level: '2'
                   }) %>
          </li>
          <%# Prerequisites is always disabled %>
          <%= render_minor_status(
                '2', 'Basics', 'Prerequisites', f, project, true
              ) %>
          <%= render_minor_status(
                '2', 'Basics', 'Project oversight', f, project, view_only
              ) %>
          <%= render_minor_status(
                '2', 'Basics', 'Other', f, project, view_only
              ) %>
          </ul>

      <% unless view_only %>
        <div class="panel-footer text-center">
          <%= t 'projects.edit.submit_cdla_permissive_20_html' %>
          <%= f.button t('projects.edit.save_and_continue'), type: 'submit', name: 'continue',
              value: 'changecontrol', class:"btn btn-success btn-submit" %>
          <%= f.submit t('projects.edit.submit_and_exit'), class:"btn btn-success btn-submit" %>
        </div>
      <% end %>
     </div>
    </div>

    <div class="panel panel-primary">
      <%= render(partial: 'panel_header',
           locals:
             {
               panel_title: 'Change Control', anchor_id: 'changecontrol',
               by_default: 'close',
               satisfaction_data:
                 project.get_satisfaction_data('2','changecontrol')
             }) %>

      <div class="panel-collapse collapse in remove-in">
        <ul class="list-group">
          <%= render_minor_status(
                '2', 'Change Control', 'Public version-controlled source repository',
                f, project, view_only
              ) %>
        </ul>
        <% unless view_only %>
          <div class="panel-footer text-center">
            <%= t 'projects.edit.submit_cdla_permissive_20_html' %>
            <%= f.button t('projects.edit.save_and_continue'), type: 'submit', name: 'continue',
              value: 'reporting', class:"btn btn-success btn-submit" %>
            <%= f.submit t('projects.edit.submit_and_exit'), class:"btn btn-success btn-submit" %>
          </div>
        <% end %>
      </div>
    </div>

    <div class="panel panel-primary">
      <%= render(partial: 'panel_header',
           locals:
             {
               panel_title: 'Quality', anchor_id: 'quality',
               by_default: 'close',
               satisfaction_data:
                 project.get_satisfaction_data('2','quality')
             }) %>
      <div class="panel-collapse collapse in remove-in">
        <ul class="list-group">
          <%= render_minor_status(
                '2', 'Quality', 'Coding standards', f, project, view_only
              ) %>
          <%= render_minor_status(
                '2', 'Quality', 'Working build system', f, project, view_only
              ) %>
          <%= render_minor_status(
                '2', 'Quality', 'Automated test suite', f, project, view_only
              ) %>
        </ul>
        <% unless view_only %>
          <div class="panel-footer text-center">
            <%= t 'projects.edit.submit_cdla_permissive_20_html' %>
            <%= f.button t('projects.edit.save_and_continue'), type: 'submit', name: 'continue',
              value: 'security', class:"btn btn-success btn-submit" %>
            <%= f.submit t('projects.edit.submit_and_exit'), class:"btn btn-success btn-submit" %>
          </div>
        <% end %>
      </div>
    </div>

    <div class="panel panel-primary">
      <%= render(partial: 'panel_header',
           locals:
             {
               panel_title: 'Security', anchor_id: 'security',
               by_default: 'close',
               satisfaction_data:
                 project.get_satisfaction_data('2','security')
             }) %>
      <div class="panel-collapse collapse in remove-in">
        <ul class="list-group">
          <li class="list-group-item"><h3 id="section_use_basic_good_cryptographic_practices"><%=
            t('Use basic good cryptographic practices',
              scope: :headings) %></h3>

            <span class="criteria-desc">
              <%= t('projects.misc.some_not_crypto_html') %>
            </span>
            <% if (!view_only) %>
              <br><br>
              <button class="btn btn-default hidden-print"
                      type="button" id='all_crypto_na'>
                <%= t('projects.misc.dont_use_crypto') %>
              </button>
              <br>
            <% end %>
            <%= render_minor_status(
                  '2', 'Security', 'Use basic good cryptographic practices',
                  f, project, view_only, false
                ) %>
          </li>
          <%= render_minor_status(
                '2', 'Security', 'Secured delivery against man-in-the-middle (MITM) attacks',
                f, project, view_only
              ) %>
          <%= render_minor_status(
                '2', 'Security', 'Other security issues',
                f, project, view_only
              ) %>
        </ul>
        <% unless view_only %>
          <div class="panel-footer text-center">
            <%= t 'projects.edit.submit_cdla_permissive_20_html' %>
            <%= f.button t('projects.edit.save_and_continue'), type: 'submit', name: 'continue',
              value: 'analysis', class:"btn btn-success btn-submit" %>
            <%= f.submit t('projects.edit.submit_and_exit'), class:"btn btn-success btn-submit" %>
          </div>
        <% end %>
      </div>
    </div>

    <div class="panel panel-primary">
      <%= render(partial: 'panel_header',
           locals:
             {
               panel_title: 'Analysis', anchor_id: 'analysis',
               by_default: 'close',
               satisfaction_data:
                 project.get_satisfaction_data('2','analysis')
             }) %>
      <div class="panel-collapse collapse in remove-in">
        <ul class="list-group">
          <%= render_minor_status(
                '2', 'Analysis', 'Dynamic code analysis',
                f, project, view_only
              ) %>
        </ul>
        <% unless view_only %>
          <div class="panel-footer text-center">
            <%= t 'projects.edit.submit_cdla_permissive_20_html' %>
            <%= f.button t('projects.edit.save_and_continue'), type: 'submit', name: 'continue',
              value: 'future', class:"btn btn-success btn-submit" %>
            <%= f.submit t('projects.edit.submit_and_exit'), class:"btn btn-success btn-submit" %>
          </div>
        <% end %>
      </div>
    </div>

  </div>
      <br>
      <div class="center">
      <% if view_only %>
        <%= t "projects.show.#{project.data_license_field}",
              user: project.user_display_name %>
      <% else %>
        <%= t 'projects.edit.submit_cdla_permissive_20_html' %>
        <%= f.button t('projects.edit.save_and_continue'), type: 'submit', name: 'continue',
          value: 'Save', class:"btn btn-success btn-submit" %>
        <%= f.submit t('projects.edit.submit_and_exit'), class:"btn btn-success btn-submit" %>
      <% end %>
      </div>
    <% end %>
  </div>
</div>
</div>
